package com.ideaction.controller;

import com.ideaction.entity.version.ClientVersion;
import com.ideaction.globalconst.ParamKey;
import com.ideaction.globalconst.Result;
import com.ideaction.req.PlayerCommonReqBody;
import com.ideaction.service.VersionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取是否有版本更新
 *
 * @author ZGame
 */
@RestController
@Slf4j
public class VersionController {
    
    @Autowired
    private VersionService versionService;
    
    @PostMapping("/UpVersion")
    public String versionUp(@RequestBody PlayerCommonReqBody playerCommonReqBody, HttpServletRequest request) {
        Result r = Result.build();
        //		ClientVersion clientVersion = versionService.versionUp(playerCommonReqBody, IpUtils.getClientIp(request));
        //		if (clientVersion == null) {
        //			return Result.buildOnlyFalse().toJsonString();
        //		}
        //		r.put("VersionResult", clientVersion.getVersionUrl());
        //		r.put("UpType", clientVersion.getUpType());
        //		r.put("ForceUp", clientVersion.isForceUp());
        //		log.info("更新客户端  old:" + playerCommonReqBody.getParam(ParamKey.VERSION) + " target:"
        //				+ clientVersion.getVersion() + " type:" + clientVersion.getUpType() + " channel:"
        //				+ playerCommonReqBody.getParam(ParamKey.CHANNEL));
        return r.response();
    }
}
